package com.lhl.express.ui.home;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProviders;

import com.lhl.express.R;
import com.lhl.express.adapter.ExpressAdapter;
import com.lhl.express.bean.Express;

import java.util.ArrayList;
import java.util.List;

public class HomeFragment extends Fragment {
    ListView lv;
    List<Express> expressList=new ArrayList<>();
    ExpressAdapter adapter;
    public View onCreateView(@NonNull LayoutInflater inflater,
                             ViewGroup container, Bundle savedInstanceState) {
        View root = inflater.inflate(R.layout.fragment_home, container, false);
        initView(root);
        getData();
        return root;
    }

    private void getData() {
        expressList.add(new Express(0,"帽子","非常好",R.mipmap.mz));
        expressList.add(new Express(0,"快递","流畅",R.mipmap.kd1));
    }

    private void initView(View root) {
        lv=root.findViewById(R.id.lv);
        adapter=new ExpressAdapter(getContext(),R.layout.express_item,expressList);
        lv.setAdapter(adapter);
    }
}